<extend name="layout/edit" />

<block name="HEADER">

</block>

<block name="CONTENT">
    <control:form id="form"/>
    <script id="tpl-moneyGridTotal" type="text/html">
    	<div style="text-align: center;">
    		<span style="margin-right: 50px;">小计</span>
    		<span  style="margin-right: 50px;">账号总额：{{get}}</span>
    		<span  style="margin-right: 50px;">余额消费：{{consume}}</span>
    		<span  style="margin-right: 50px;">账号余额：{{money}}</span>
    	</div>
    </script>
    <script id="tpl-integralGridTotal" type="text/html">
    	<div style="text-align: center;">
    		<span style="margin-right: 50px;">小计</span>
    		<span  style="margin-right: 50px;">积分获赠：{{get}}</span>
    		<span  style="margin-right: 50px;">积分消费：{{consume}}</span>
    		<span  style="margin-right: 50px;">积分余额：{{money}}</span>
    	</div>
    </script>
</block>

<block name="FOOTER">
   <script type="text/javascript">
    var  page=(function(ns){
    	
		ns.init = function(){
			var filter=[{"field":"id","opera":"=","value":__oid}];            
			
			//累计消费
			var consume_total = form.getValue("consume_total");
			$("#consume .line h3").append('<span style="margin-left: 30px;">'+consume_total+'</span>');
            consumeGrid = layui.grid.render("consumeGrid"); 
          	consumeGrid.load([]);    
          	
          	//账号余额
          	var money = form.getValue("balance");
			$("#money .line h3").append('<span style="margin-left: 30px;">'+money+'</span>');
            moneyGrid = layui.grid.render("moneyGrid"); 
          	moneyGrid.load([]);    
          	moneyGrid.loadSuccess(function(e){
          		$("#moneyGridTotal").html( template("tpl-moneyGridTotal",{
          			get:'1000.00',
          			consume:"500.00",
          			money:"500.00"
          		}));
          	});
          	
          	//积分余额
          	var integral = form.getValue("integral");
			$("#integral .line h3").append('<span style="margin-left: 30px;">'+integral+'</span>');
            integralGrid = layui.grid.render("integralGrid"); 
          	integralGrid.load([]);    
          	integralGrid.loadSuccess(function(e){
          		$("#integralGridTotal").html( template("tpl-integralGridTotal",{
          			get:'1000.00',
          			consume:"500.00",
          			money:"500.00"
          		}));
          	});
          	
          	//推荐会员数量
          	var spread = form.getValue("spread");
			$("#spread .line h3").append('<span style="margin-left: 30px;">'+integral+'</span>');
            spreadGrid = layui.grid.render("spreadGrid"); 
          	spreadGrid.load([]);    
		}
    	
        //保存
        ns.save=function(){
    		form.save(1).then(function(res){
            	form.opener.grid.load();
            });
        }
        
        return ns;
    }({}));
    
    $(function(){ page.init(); });
   </script>
</block>



